﻿<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Movies.aspx.vb" Inherits="TheatreStaff_Movies" %>
<%@ Register TagPrefix="custom" Namespace="myControls" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">



'    if( Eval("ticketsold") >0)

'    { Response.Write("Hello");
'}

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<script type="text/javascript">
        
        function displayCalendar()
        {
            var datePicker = document.getElementById('datePicker');
            datePicker.style.display = 'block';
        }
</script>
<script runat ="server" >
 

'protected void test3(object sender, EventArgs e)
'{
'    Label3.Text = txtMovieTitle.Text;
'CompareValidator1.Visible = false;
'}
'protected void Cancel(object sender, EventArgs e)
'{

'    txtMovieTitleI.Text = string.Empty;
'    txtMovieDirectorI.Text = string.Empty;
'    chkShowingI.Checked = false;
'    txtMovieDescriptionI.Text = string.Empty;
'    txtMovieDurationI.Text = string.Empty;
'    txtimagefnameI.Text = string.Empty;
'    txtRatingI.Text = string.Empty;
'    txtTrailersI.Text = string.Empty;
'    txtTheatreDateReleasedI.Text = string.Empty;
'    txtMaincastI.Text = string.Empty;
'    Label15.Text = string.Empty;
'    Label16.Text = string.Empty;
'    ddlCategoryI.SelectedIndex = -1;
'    grdMovie.DataBind();
'}

</script>
<script type="text/javascript">
function showInsert() {
    var divInsert = document.getElementById('divInsert');
    divInsert.style.display = 'block';
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
</script>
 <style type="text/css">
        #datePicker
        {
            display:none;
            position:absolute;
            border:solid 2px black;
            background-color:white;
           
        }
    
    </style>
<style type="text/css">
#divDisplay
{
    border:solid 1px White;
    width:400px;
    padding:15px;
    margin:0px auto;
    text-align:center;
    border:1px solid #333;
}
.C
{
     color:#FFFFCC;
    font-size:larger;
    font-weight :bolder ;
}
.I
{
    color:red;
    font-size:larger;
    font-weight :bolder ;
}
#divInsert
{
    display:none;
    border:solid 1px black;
    width:500px;
    position:absolute;
    top:200px;
    left:100px;
    padding:10px;
    background-color:Silver;
    color:Black ;
}
.center1
{
    padding-left:320px;
}
html
{
  background-image:url('image/back.jpg'); 

    padding:10px;
    color:White;    
  
}
.content
{
           width:950px;
    margin:auto;
        height: 197px;
  
    }
.content1
{
    margin:auto;
    width:850px;
  
}
.column
{
    float:left;
    width:348px;
}
.selectedRow
{
    background-color:Gray;
}

content
{
    width:950px;
    margin:auto;
        height: 197px;
}

.link
{
  margin-left:350px; 
     font-weight:bold;
  font-size:large;  
    font-size:x-large;
}
.link2
{
  margin-left:50px; 
     font-weight:bold;
  font-size:large;  
    font-size:x-large;
}
a
{
 color: white;
 text-decoration:underline;
 font-weight:bold;

}
a:hover
{
 color: red; 
  text-decoration:none;
  font-weight:bold;

}
.join
{
   background-color:#0099FF;
  clip:auto;
  font-weight:bold;
  font-size:large;
}
.table2
{
 border-style:solid;
   border-color:Black;
   background-color:White;
   color:Black;  
   width:900px; 
}
.row
{
   background-color:Gray;
   color:White;
}
.ticket
{
   background-color:#CC0000;
color:White;

}

.ticket:hover
{
 color: black; 
  text-decoration:none;


}
        
.footer
{

     font-weight:bold;
  font-size:large;  

}
.ticket1
{
    padding-left:200px;
}
.view2
{
 padding-left:180px;  
}

     .menu
{
 padding-left:150px;  

}
.text
{
 font-weight:bold;
}
.button
{
 margin-left:250px;
}
.view3
{
    padding-left:120px;
}
.footer
{

   margin-top:50px;
}
.center
{
    padding-left:340px;
}
.cinema
{
    padding-left:590px;
}
.bullet
{
 padding-left:20px;  
}
    .style2
    {
        width: 603px;
    }
    .movieList:hover
{
 color: White; background-color:rgba(255,0,0,.75); 
}
</style>
    <title>Movie Maintenance Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div class="content">
  <asp:Image ID="Image1" Width="1000" Height="130" ImageUrl="~/image/tdk-jun5-bannerbatmanexclusivo2.jpg" runat="server" /><br />
<asp:HyperLink ID="HyperLink14"  CssClass="link" NavigateUrl="~/Default.aspx" runat="server">Home</asp:HyperLink>
<asp:HyperLink ID="HyperLink1"  CssClass="link2" NavigateUrl="~/Session.aspx" runat="server">Session</asp:HyperLink> <asp:HyperLink ID="HyperLink2" CssClass="link2" NavigateUrl="~/Movie.aspx" runat="server">Movies</asp:HyperLink>
<asp:HyperLink ID="HyperLink3" CssClass="link2"  NavigateUrl="~/Price.aspx" runat="server">Prices</asp:HyperLink>

<br /> 
<br /> 
   <%--<asp:Label ID="Label05" runat="server"  Text="Theatre" CssClass="cinema" Font-Bold="True" Font-Underline="True"></asp:Label>
        <asp:Label ID="Label2" runat="server"  ForeColor="Yellow"></asp:Label>
      
&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp 
          <asp:Label ID="Label5" runat="server" Text="UserName" Font-Bold="True"></asp:Label>    <asp:LoginName ID="LoginName1" runat="server" /> 
    &nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp<asp:LoginStatus ID="LoginStatus1" runat="server" ForeColor="#99CCFF" />--%>
<table class="center1" >
        <tr>
            <td >
               <asp:Label ID="Label22222" runat="server"  CssClass="menu" Text="Theatre" Font-Bold="True" Font-Underline="True"></asp:Label>  
            </td>
            <td>
                 <asp:Label ID="Label2" runat="server"  ForeColor="Yellow"></asp:Label>
                                         &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;
                 </td>
            <td>
                <asp:Label ID="Label12" runat="server" Text="UserName" Font-Bold="True"></asp:Label>
            </td>
            <td>
                <asp:LoginName ID="LoginName1" runat="server" /> 
                &nbsp;&nbsp;&nbsp;
            </td>
            <td>
                 <asp:LoginStatus ID="LoginStatus1" runat="server" ForeColor="#99CCFF" />
                 &nbsp;&nbsp;&nbsp;
            </td>
        </tr>
    </table>
        <hr />
  <asp:Label ID="Label8" runat="server" Text="Maintain:" Font-Bold="True" Font-Size="Larger" Font-Underline="True"></asp:Label>
<asp:HyperLink ID="HyperLink4" runat="server" 
            NavigateUrl="~/TheatreStaff/Cinema.aspx" ForeColor="#FFCC99">[Cinemas]</asp:HyperLink>&nbsp;&nbsp;
    <asp:HyperLink ID="HyperLink5" runat="server"  ForeColor="#FFFF99" NavigateUrl="~/TheatreStaff/Movies.aspx">[Movies]</asp:HyperLink> &nbsp;
    <asp:HyperLink ID="HyperLink144" runat="server" NavigateUrl="~/TheatreStaff/Schedule.aspx" ForeColor="#FF9900">[Schedules]</asp:HyperLink>&nbsp;   
 <asp:HyperLink ID="HyperLink117" runat="server" NavigateUrl="~/TheatreStaff/Session.aspx" ForeColor="#FF6699">[Session Times]</asp:HyperLink>&nbsp; 
  <asp:HyperLink ID="HyperLink116" runat="server" NavigateUrl="~/TheatreStaff/SessionDates.aspx" ForeColor="#66FF66">[Session Date]</asp:HyperLink>&nbsp;    
 <asp:HyperLink ID="HyperLink115" runat="server" NavigateUrl="~/TheatreStaff/SpecialTickets.aspx" ForeColor="Aqua">[Specail Price]</asp:HyperLink>&nbsp;
 <asp:HyperLink ID="HyperLink107" runat="server" NavigateUrl="~/TheatreStaff/specialday.aspx" ForeColor="#CCFF33">[Special Ticket Pricing Days]</asp:HyperLink>&nbsp;  
    <asp:HyperLink ID="HyperLink6" runat="server" NavigateUrl="~/TheatreStaff/SalesReports.aspx" ForeColor="#CCFFFF">[Sales Report]</asp:HyperLink>&nbsp;
        <asp:HyperLink ID="HyperLink11" runat="server" NavigateUrl="~/TheatreStaff/AddNewUser.aspx" ForeColor="#66FF99">[Add New User]</asp:HyperLink>&nbsp; 
  <hr />
        <div class ="content1">
      
        <asp:Label ID="lblId" runat="server" Visible="false" ></asp:Label>
        
     
           <h3><asp:Label ID="Label1" Text ="Movie Maintenance" runat="server" CssClass="center" ForeColor="#FFFF99" /></h3>
                
               <asp:BulletedList ID="BulletedList2"  CssClass="bullet" ForeColor="White" runat="server">
               <%--<asp:ListItem  Text="When you insert the release date, please folow the format: dd/mm/yyyy" />--%>
               <asp:ListItem Text="Click 'Select' to view more details" />
               <asp:ListItem Text="Click 'Edit' to view the update screen to update movie details. You can not change an existing movie to another movie which already exist (Movie Title and Director)" />
               <asp:ListItem Text="Click 'Cancel' to return to the Movie Maintenance section" />
               <asp:ListItem Text="Click 'Delete' to delete a movie , when you do not see 'Delete' that means the tickets are sold and you can not delete that movie" />
               <asp:ListItem Text="Click 'Insert Movie' to insert a new movie. You can not insert a movie (Movie Title and Director)  which already exist " />
        </asp:BulletedList>
            
          
                 <asp:ScriptManager ID="ScriptManager1" runat="server" />
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
           <ContentTemplate>
            <div class="column">
            <asp:Label ID="Label15" CssClass="I" runat="server"  ></asp:Label> 
                    <%--<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="CustomValidator"></asp:CustomValidator>--%>
                    <%--<asp:RequiredFieldValidator ID="reqError" runat="server" ControlToValidate="lblError" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>--%>
                    
             <asp:Label ID="Label16" CssClass="C" runat="server" ></asp:Label>
            
                
            <asp:GridView
            id="grdMovie"
            DataSourceID="srcMoviegrd"
            DataKeyNames="MovieId"
            AutoGenerateColumns = "false" OnSelectedIndexChanged ="Clear"
            AutoGenerateSelectButton="True"
            SelectedRowStyle-CssClass="selectedRow" 
            Runat="server" Height="67px" Width="279px"
            AllowPaging="True" RowStyle-CssClass="movieList">
            <Columns>

            <%--<asp:TemplateField>--%>
            <%--<ItemTemplate>
            <%--<asp:LinkButton ID="GridDeleteButton"   runat="server" Text="Delete" CommandName="Delete"  Visible='<%#test(Eval("ticketsold"))%>' />--%>
            <%--<asp:LinkButton ID="LinkButton1"   runat="server" Text="Delete" CommandName="Delete"     />--%>
            <%--</ItemTemplate>--%>

            <asp:BoundField DataField ="MovieTitle"  HeaderText ="Movie Title"/>
           <asp:BoundField DataField="MovieID" HeaderText="Movie ID" />
            <asp:BoundField DataField="ticketsold" HeaderText="Ticket Sold" />
                          <asp:TemplateField>
            <ItemTemplate>
            <asp:LinkButton ID="GridDeleteButton" OnClientClick='return confirm("Are you sure you want to delete this movie?");'  runat="server" Text="Delete" CommandName="Delete" Visible='<%# test(Eval("ticketsold"))%>'    />
            </ItemTemplate>
            </asp:TemplateField>
   <%-- <custom:DeleteButtonField CommandName="Delete"  ConfirmText ="Are you sure that you want to delete this record?" />--%>
            </Columns>
             <%--</asp:TemplateField>--%>
         </asp:GridView>
        <%--<SelectedRowStyle CssClass="selectedRow"></SelectedRowStyle>--%>
       <asp:HyperLink ID="HyperLink17" NavigateUrl ="~/TheatreStaff/InsertMovie.aspx" runat="server">Insert Movie</asp:HyperLink>
        <%--<a href="JavaScript:showInsert();">Insert Movie</a>--%>
       </div>
          <%--<asp:LinkButton ID="LinkButton1" OnClick="CheckDelete" runat="server">Delete</asp:LinkButton>--%>
          <div class="column"> 
              <asp:Label ID="Label3" runat="server" Visible="false"  ></asp:Label><br />
              <asp:Label ID="Label6" runat="server" Text="Label" Visible="false"></asp:Label>
              <asp:Label ID="Label4" runat="server" Visible="false"></asp:Label>
              
                 <asp:UpdatePanel ID="UpdatePanel2" runat="server">
           <ContentTemplate>
                    <asp:DetailsView ID="dtlMovie" DataSourceID="srcMovie" 
                    AutoGenerateEditButton="true" AutoGenerateRows ="false" runat="server" 
                        Height="484px" Width="406px" DataKeyNames="MovieId" 
                        OnItemInserting ="btnOk_Click"  
                        OnItemUpdated ="dtlSchedule_ItemUpdated"
                         AllowPaging ="false">
                        <Fields>
                           <asp:TemplateField HeaderStyle-Font-Bold="true" HeaderText="Movie Title" 
                           SortExpression ="MovieTitle">
                                <ItemTemplate>
                                  <%# Eval("MovieTitle")%>
                                </ItemTemplate>
                                <EditItemTemplate>
                               
                                  
                                  <asp:TextBox
                                    id="txtMovieTitle"
                                    Text='<%# Bind("MovieTitle") %>'
                                    Runat="server"   OnDataBinding="function2"    />
                                    <asp:CustomValidator  ControlToValidate="txtMovieTitle" OnServerValidate="function1" ID="CustomValidator1" runat="server" ErrorMessage="This title and this director already exist!" Font-Size="Larger" />               
                                    
                        
                                  <asp:RequiredFieldValidator
                                    id="reqMovieTitle"
                                    ControlToValidate="txtMovieTitle"
                                    Text="(Required)"
                                    Runat="server" />
                     
                                </EditItemTemplate>
                           </asp:TemplateField> 
                               
                               <asp:TemplateField HeaderStyle-Font-Bold="true" HeaderText="Category Name" 
                           SortExpression ="CategoryID">
                                <ItemTemplate>
                                  <%# Eval("MovieCategoryName")%>
                                </ItemTemplate>
                                <EditItemTemplate>
                                   <asp:DropDownList 
                                    ID="ddlCategory" 
                                     DataSourceID ="srcCategory" 
                                     DataTextField ="MovieCategoryName" SelectedValue='<%# Bind("CategoryId") %>'
                                     DataValueField ="MovieCategoryId"
                                     runat="server" AppendDataBoundItems ="true" >
                                     <asp:ListItem Text ="Select" Value ="-1" />
                                    </asp:DropDownList> 
                                  <asp:RequiredFieldValidator
                                    id="reqcategoryID"
                                    ControlToValidate="ddlCategory" 
                                    Text="(Required)" InitialValue ="-1"
                                    Runat="server" />    
                                </EditItemTemplate> 
                               </asp:TemplateField> 
                               
                                <asp:TemplateField HeaderStyle-Font-Bold="true" HeaderText="Movie Director">
                                <ItemTemplate>
                                  <%# Eval("MovieDirector")%>
                                </ItemTemplate>
                                <EditItemTemplate>
                                  <asp:TextBox OnDataBinding="function3"
                                    id="txtMovieDirector"
                                    Text='<%# Bind("MovieDirector") %>'
                                    Runat="server"   />
                                  
                                  <asp:RequiredFieldValidator
                                    id="reqMovieDirector"
                                    ControlToValidate="txtMovieDirector"
                                    Text="(Required)"
                                    Runat="server" />    
                                </EditItemTemplate>
                               </asp:TemplateField> 
                               
                                <asp:TemplateField HeaderStyle-Font-Bold="true" HeaderText="Now Showing">
                                <ItemTemplate>
                                  <%# Eval("Showing")%>
                                </ItemTemplate>
                                <EditItemTemplate>
                                  <asp:CheckBox ID="chkShowing"
                                   Checked ='<%# Bind("Showing") %>'
                                    runat="server" />
                                 <%-- <asp:TextBox
                                    id="txtShowing"
                                    Text='<%# Bind("Showing") %>'
                                    Runat="server" />--%>
                                <%--  <asp:RequiredFieldValidator
                                    id="reqShowing"
                                    ControlToValidate="chkShowing"
                                    Text="(Required)"
                                    Runat="server" /> --%>   
                                </EditItemTemplate>
                               </asp:TemplateField> 
                               
                                <asp:TemplateField HeaderStyle-Font-Bold="true" HeaderText="Movie Description">
                                <ItemTemplate>
                                  <%# Eval("MovieDescription")%>
                                </ItemTemplate>
                                <EditItemTemplate>
                                  <asp:TextBox
                                    id="txtMovieDescription"
                                    Text='<%# Bind("MovieDescription") %>'
                                    Runat="server" TextMode="MultiLine" />
                                  <asp:RequiredFieldValidator
                                    id="reqMovieDescription"
                                    ControlToValidate="txtMovieDescription"
                                    Text="(Required)"
                                    Runat="server" />    
                                </EditItemTemplate>
                               </asp:TemplateField> 
                               
                                <asp:TemplateField HeaderStyle-Font-Bold="true" HeaderText="Movie Duration">
                                <ItemTemplate>
                                  <%# Eval("MovieDuration")%>
                                </ItemTemplate>
                                <EditItemTemplate>
                                  <asp:TextBox
                                    id="txtMovieDuration"
                                    Text='<%# Bind("MovieDuration") %>'
                                    Runat="server" />
                                  <asp:RequiredFieldValidator
                                    id="reqMovieDuration"
                                    ControlToValidate="txtMovieDuration"
                                    Text="(Required)"
                                    Runat="server" />    
                                </EditItemTemplate>
                               </asp:TemplateField> 
                               
                                <asp:TemplateField HeaderStyle-Font-Bold="true" HeaderText="Image Name">
                                <ItemTemplate>
                                  <%# Eval("imagefname")%>
                                </ItemTemplate>
                                <EditItemTemplate>
                                  <asp:TextBox
                                    id="txtimagefname"
                                    Text='<%# Bind("imagefname") %>'
                                    Runat="server" />
                                  <asp:RequiredFieldValidator
                                    id="reqimagefname"
                                    ControlToValidate="txtimagefname"
                                    Text="(Required)"
                                    Runat="server" />    
                                </EditItemTemplate>
                               </asp:TemplateField> 
                               
                                <asp:TemplateField HeaderStyle-Font-Bold="true" HeaderText="Movie Rating">
                                <ItemTemplate>
                                  <%# Eval("Rating")%>
                                </ItemTemplate>
                                <EditItemTemplate>
                                  <asp:TextBox
                                    id="txtRating"
                                    Text='<%# Bind("Rating") %>'
                                    Runat="server" />
                                  <asp:RequiredFieldValidator
                                    id="reqRating"
                                    ControlToValidate="txtRating"
                                    Text="(Required)"
                                    Runat="server" />    
                                </EditItemTemplate>
                               </asp:TemplateField> 
                                 <asp:TemplateField HeaderStyle-Font-Bold="true" HeaderText="Movie Trailer">
                                <ItemTemplate>
                                  <%# Eval("Trailers")%>
                                </ItemTemplate>
                                <EditItemTemplate>
                                  <asp:TextBox
                                    id="txtTrailers"
                                    Text='<%# Bind("Trailers") %>'
                                    Runat="server" />
                                  <asp:RequiredFieldValidator
                                    id="reqTrailers"
                                    ControlToValidate="txtTrailers"
                                    Text="(Required)"
                                    Runat="server" />    
                                </EditItemTemplate>
                               </asp:TemplateField>
                                <asp:TemplateField HeaderStyle-Font-Bold="true" HeaderText="Theatre Release Date">
                                <ItemTemplate>
                                  <%# Eval("TheatreDateReleased","{0:d}")%>
                                </ItemTemplate>
                                <EditItemTemplate>
                                  <asp:TextBox
                                    id="txtTheatreDateReleased"
                                    Text='<%# Bind("TheatreDateReleased","{0:dd/MM/yyyy}") %>'
                                    Runat="server" />
                                    <asp:RegularExpressionValidator 
                     ID="RegularExpressionValidator2I" 
                     ControlToValidate="txtTheatreDateReleased" 
                     runat="server" 
                     ErrorMessage="(Please enter a valid date in the dd/MM/yyyy format)"
                      ValidationExpression="(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d">
                      </asp:RegularExpressionValidator>
                                    <%--<asp:CompareValidator ControlToValidate="txtTheatreDateReleased" Type="Date" Operator="DataTypeCheck" ID="CompareValidator1" runat="server" ErrorMessage="please follow format dd/mm/yyyy"></asp:CompareValidator>            
                                  <asp:RequiredFieldValidator
                                    id="reqTheatreDateReleased"
                                    ControlToValidate="txtTheatreDateReleased"
                                    Text="(Required)"
                                    Runat="server" /> 
                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" ControlToValidate="txtTheatreDateReleased" runat="server" ErrorMessage="(Please enter a valid date in the mm/dd/yyyy format)" ValidationExpression="(0[1-9]|1[012])[ /](0[1-9]|[12][0-9]|3[01])[ /](19|20)\d\d"></asp:RegularExpressionValidator>--%>
                                    
                                </EditItemTemplate>
                               </asp:TemplateField> 
                                <asp:TemplateField HeaderStyle-Font-Bold="true" HeaderText="Main Cast">
                                <ItemTemplate>
                                  <%# Eval("Maincast")%>
                                </ItemTemplate>
                                <EditItemTemplate>
                                  <asp:TextBox
                                    id="txtMaincast"
                                    Text='<%# Bind("Maincast") %>'
                                    Runat="server" TextMode="MultiLine" />
                                  <asp:RequiredFieldValidator
                                    id="reqMaincast"
                                    ControlToValidate="txtMaincast"
                                    Text="(Required)"
                                    Runat="server" /> 
                                </EditItemTemplate>

                               </asp:TemplateField>

                            
                        </Fields>  
                        
                    </asp:DetailsView>
                      </ContentTemplate>
               </asp:UpdatePanel>
        </div>
          </ContentTemplate>
               </asp:UpdatePanel>
        </div>
     <%--<div id="divInsert">
        <fieldset >
            <legend >Insert Movie</legend>
            <table>
                
                <tr>
                <td>
                    <asp:Label ID="Label3" runat="server" Text="Movie Title"></asp:Label>
                </td>
                <td>
                    <asp:TextBox
                    id="txtMovieTitleI"
                    Runat="server"/>
                </td>
                <td colspan ="2">
                  <asp:RequiredFieldValidator
                    id="reqMovieTitleI"
                    ControlToValidate="txtMovieTitleI"
                    Text="(Required)"
                    Runat="server" />  
                </td> 
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label4" runat="server" Text="Movie Category"></asp:Label>
                </td>
                <td>
                   <asp:DropDownList 
                    ID="ddlCategoryI" 
                     DataSourceID ="srcCategory" 
                     DataTextField ="MovieCategoryName" 
                     DataValueField ="MovieCategoryId" 
                     runat="server" AppendDataBoundItems ="true" >
                     <asp:ListItem Text ="Select" Value ="-1" />
                    </asp:DropDownList> 
                </td>
                <td colspan ="2">
                   <asp:RequiredFieldValidator
                        id="reqcategoryIDI"
                        ControlToValidate="ddlCategoryI" 
                        Text="(Required)" InitialValue ="-1"
                        Runat="server" />   
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label6" runat="server" Text="Movie Director"></asp:Label>
                </td>
                <td>
                     <asp:TextBox
                        id="txtMovieDirectorI"
                        Runat="server" />
                </td>
                <td colspan ="2">
                    <asp:RequiredFieldValidator
                        id="reqMovieDirectorI"
                        ControlToValidate="txtMovieDirectorI"
                        Text="(Required)"
                        Runat="server" />
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label7" runat="server" Text="Showing"></asp:Label>  
                </td>
                <td colspan="3">
                     <asp:CheckBox ID="chkShowingI"
                    runat="server" />
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label8" runat="server" Text="Movie Description"></asp:Label>
                </td>
                <td>
                    <asp:TextBox
                    id="txtMovieDescriptionI"
                    Runat="server" TextMode="MultiLine" />
                </td>
                <td colspan ="2">
                    <asp:RequiredFieldValidator
                    id="reqMovieDescriptionI"
                    ControlToValidate="txtMovieDescriptionI"
                    Text="(Required)"
                    Runat="server" /> 
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label9" runat="server" Text="Movie Duration"></asp:Label>
                </td>
                <td>
                    <asp:TextBox
                    id="txtMovieDurationI"
                    Runat="server" />
                </td>
                <td colspan ="2">
                     <asp:RequiredFieldValidator
                    id="reqMovieDurationI"
                    ControlToValidate="txtMovieDurationI"
                    Text="(Required)"
                    Runat="server" />  
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label10" runat="server" Text="Image Name"></asp:Label>
                </td>
                <td>
                    <asp:TextBox
                    id="txtimagefnameI"
                    Runat="server" />
                </td>
                <td colspan ="2">
                    <asp:RequiredFieldValidator
                    id="reqimagefnameI"
                    ControlToValidate="txtimagefnameI"
                    Text="(Required)"
                    Runat="server" />
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label11" runat="server" Text="Movie Rating"></asp:Label>
                </td>
                <td>
                  <asp:TextBox
                    id="txtRatingI"
                    Runat="server" />
                </td>
                <td colspan ="2">
                    <asp:RequiredFieldValidator
                    id="reqRatingI"
                    ControlToValidate="txtRatingI"
                    Text="(Required)"
                    Runat="server" />  
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label12" runat="server" Text="Trailers"></asp:Label>
                </td>
                <td>
                    <asp:TextBox
                    id="txtTrailersI"
                    Runat="server" />
                </td>
                <td colspan ="2">
                     <asp:RequiredFieldValidator
                    id="reqTrailersI"
                    ControlToValidate="txtTrailersI"
                    Text="(Required)"
                    Runat="server" />    
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label13" runat="server" Text="Theatre Release Date"></asp:Label>
                </td>
                <td>
                    <asp:TextBox
                    id="txtTheatreDateReleasedI"
                    Runat="server" />
                </td>
                <td>
                     <asp:RequiredFieldValidator
                    id="reqTheatreDateReleasedI"
                    ControlToValidate="txtTheatreDateReleasedI"
                    Text="(Required)"
                    Runat="server" /> 
                </td>
                <td>
                     <asp:RegularExpressionValidator 
                     ID="RegularExpressionValidator1I" 
                     ControlToValidate="txtTheatreDateReleasedI" 
                     runat="server" 
                     ErrorMessage="(Please enter a valid date in the mm/dd/yyyy format)"
                      ValidationExpression="(0[1-9]|1[012])[ /](0[1-9]|[12][0-9]|3[01])[ /](19|20)\d\d">
                      </asp:RegularExpressionValidator>
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label14" runat="server" Text="Main Cast"></asp:Label>
                </td>
                <td>
                    <asp:TextBox
                    id="txtMaincastI"
                    Runat="server" TextMode="MultiLine" />
                </td>
                <td colspan ="2">
                    <asp:RequiredFieldValidator
                    id="reqMaincastI"
                    ControlToValidate="txtMaincastI"
                    Text="(Required)"
                    Runat="server" /> 
                </td>
                </tr>
                </table>
                <table>
                <tr>
                <td>
                    
                    <asp:LinkButton ID="btnInsert" OnClick ="InsertMovie_Click" runat="server">Insert Movie</asp:LinkButton>
                </td>
                <td>
                    <asp:LinkButton ID="btnCancel" OnClick ="Cancel" CommandName="Cancel" CausesValidation ="false"  runat="server">Cancel</asp:LinkButton>
                </td>
                </tr>
            </table>
        </fieldset>--%>

     
     
     
        <asp:SqlDataSource ID="srcMoviegrd" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        SelectCommand="SELECT DISTINCT Movie.MovieTitle, Movie.MovieId, Movie.ticketsold, 
        TheatreStaff.TheatreStaffUserName FROM Movie INNER JOIN TheatreStaff ON Movie.TheatreId =
         TheatreStaff.TheatreId WHERE (TheatreStaff.TheatreStaffUserName = @username)Order By Movie.MovieTitle"
        DeleteCommand ="DELETE Movie WHERE MovieId=@MovieId" >
            <SelectParameters>
                <asp:Parameter Type="String" Name="username" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="MovieId" />
            </DeleteParameters>
        </asp:SqlDataSource>
     
     
        <%--<asp:SqlDataSource ID="srcMoviegrd" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        SelectCommand="SELECT Movie.MovieTitle, Movie.MovieId, datesession.ticketsold FROM Movie INNER JOIN TheatreStaff ON Movie.TheatreId = TheatreStaff.TheatreId INNER JOIN datesession ON Movie.MovieId = datesession.movieid WHERE (TheatreStaff.TheatreStaffUserName = @username)"
        DeleteCommand ="DELETE Movie WHERE MovieId=@MovieId" >
            <SelectParameters>
                <asp:Parameter  Type="String"  Name="username" DefaultValue="adam" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="MovieId" />
            </DeleteParameters>
        </asp:SqlDataSource>--%>
        
        <asp:SqlDataSource ID="srcMovie" 
            SelectCommand ="SELECT Movie.MovieId,Movie.MovieTitle,Movie.MovieDirector,Movie.Showing,
            Movie.MovieDescription,Movie.TheatreId,Movie.MovieDuration,
            Movie.imagefname,Movie.Rating,Movie.Trailers,Movie.TheatreDateReleased,
            Movie.Maincast, Movie.CategoryID,MovieCategory.MovieCategoryName FROM Movie,TheatreStaff,MovieCategory 
            Where Movie.TheatreId=TheatreStaff.TheatreId AND TheatreStaff.TheatreStaffUserName=@username 
            AND Movie.MovieId=@MovieId AND MovieCategory.MovieCategoryId=Movie.CategoryId Order by Movie.MovieTitle" 
            InsertCommand="INSERT INTO Movie(MovieTitle,MovieDirector,Showing,
            MovieDescription,TheatreId,MovieDuration,
            imagefname,Rating,Trailers,TheatreDateReleased,
            Maincast,CategoryID)
            VALUES (@MovieTitle,@MovieDirector,@Showing,
            @MovieDescription,@TheatreId,@MovieDuration,
            @imagefname,@Rating,@Trailers,@TheatreDateReleased,
            @Maincast,@CategoryID)"
            UpdateCommand ="UPDATE Movie SET MovieTitle=@MovieTitle,MovieDirector=@MovieDirector,Showing=@Showing,
            MovieDescription=@MovieDescription,MovieDuration=@MovieDuration,
            imagefname=@imagefname,Rating=@Rating,Trailers=@Trailers,TheatreDateReleased=@TheatreDateReleased,
            Maincast=@Maincast,CategoryID=@CategoryID WHERE MovieId=@MovieId" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>"  runat="server" >
             <SelectParameters>
                  <asp:Parameter Name ="username" Type ="string"  /> 
                   <asp:ControlParameter Name ="MovieId" ControlID ="grdMovie" />
             </SelectParameters>
             <InsertParameters >
                   <asp:Parameter Name="TheatreId" DbType="Int32"  />
            </InsertParameters>
            <UpdateParameters >
                   <asp:Parameter Name ="MovieId" DbType ="Int32" />
                   <asp:Parameter DbType ="String" Name ="MovieTitle" />
                   <asp:Parameter DbType ="String" Name ="MovieDirector" />
                   <asp:Parameter DbType ="Boolean" Name ="Showing" />
                   <asp:Parameter DbType ="String" Name ="MovieDescription" />
                   <asp:Parameter DbType ="String" Name ="MovieDuration" />
                   <asp:Parameter DbType ="String" Name ="imagefname" />
                   <asp:Parameter DbType ="String" Name ="Rating" />
                   <asp:Parameter DbType ="String" Name ="Trailers" />
                   <asp:Parameter DbType ="Date" Name ="TheatreDateReleased" />
                   <asp:Parameter DbType ="String" Name ="Maincast" />
                   <asp:Parameter DbType ="String" Name ="CategoryID" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="srcCategory" runat="server"  ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand ="SELECT DISTINCT MovieCategory.MovieCategoryId,MovieCategory.MovieCategoryName FROM MovieCategory">
                <SelectParameters >
                    <asp:ControlParameter Name ="TheatreId" ControlID ="lblId"/>
                </SelectParameters>
            </asp:SqlDataSource>
   
  <table align="left"  cellpadding="15" ><tr><td>Copyright@2012 MovieTix</td><td><asp:HyperLink ID="HyperLink8"  CssClass="footer" NavigateUrl="~/Default.aspx" runat="server">Homepage</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink9"  CssClass="footer" NavigateUrl="~/TheatreStaff/Session.aspx" runat="server">Session</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink10"  CssClass="footer" NavigateUrl="~/TheatreStaff/Movies.aspx" runat="server">Movies</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink12"  CssClass="footer" NavigateUrl="~/register.aspx" runat="server">Register</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink13"  CssClass="footer" NavigateUrl="~/Login.aspx" runat="server">Log In</asp:HyperLink></td></tr></table>
            </div>
    </form>
</body>
</html>